<?php

namespace Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/** @ORM\Entity */
class User
{
     
    /** @ORM\Id() @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO") @var int */
    private $id;
     
    /** @ORM\Column(type="string", length=255) @var string */
    private $login;
     
    /**
     * @ORM\OneToMany(targetEntity="Entity\Comment", mappedBy="user")
     * @var Collection
     */
    private $comments;
     
    public function __construct($login) {
        //Initializing collection. Doctrine recognizes Collections, not arrays!
        $this->comments = new ArrayCollection();
        $this->setLogin($login);
    }
     
    //Getters and setters
     
    /** @return Collection */
    public function getComments() {
        return $this->comments;
    }
     
    /** @param Comment $comment */
    public function addComment(Comment $comment) {
        $this->comments->add($comment);
        $comment->setUser($this);
    }
 

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set login
     *
     * @param string $login
     * @return User
     */
    public function setLogin($login)
    {
        $this->login = $login;
    
        return $this;
    }

    /**
     * Get login
     *
     * @return string 
     */
    public function getLogin()
    {
        return $this->login;
    }

    /**
     * Remove comments
     *
     * @param \Entity\Comment $comments
     */
    public function removeComment(\Entity\Comment $comments)
    {
        $this->comments->removeElement($comments);
    }
}